package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.User1;
import com.cskaoyan.bean.User2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author stone
 * @date 2022/07/13 11:25
 */
@RestController
public class HelloController {

    @Autowired
    ConfigurableConversionService conversionService;

    @RequestMapping("hello")
    public BaseRespVo hello() {
        return BaseRespVo.ok("hello");
    }

    //localhost:8080/user/register?user=songge
    @RequestMapping("user/register")
    //public BaseRespVo register(String user) {
    //public BaseRespVo register(User1 user) {
    public BaseRespVo register(User2 user) {  //user2
        //考虑使用Converter → 请求参数名和Handler方法的形参名一致
        // 可以提供Converter    String → User2
        return BaseRespVo.ok(null);
    }

    @RequestMapping("user/register2")
    //public BaseRespVo register(String user) {
    //public BaseRespVo register(User1 user) {
    public BaseRespVo register2(User2 user2) {
        //考虑使用Converter → 请求参数名和Handler方法的形参名一致
        // 可以提供Converter    String → User2
        return BaseRespVo.ok(null);
    }
}
